import json

# 创建一个字典，键名从 "s1" 开始，依次递增到 "s20"
config_data = {f"s{i}": True for i in range(1, 100)}

# 将字典转换为JSON并写入文件
with open('device_id.json', 'w') as json_file:
    json.dump(config_data, json_file, indent=4)

print("JSON配置文件已生成。")



# # 读取config.json文件并转换为Python字典
# with open('device_id.json', 'r') as json_file:
#     config_data = json.load(json_file)
#
# # 输出转换后的Python字典
# print("转换后的Python字典：")
# print(config_data)
#
# # 遍历字典并打印键和值
# print("字典的键和值：")
# for key, value in config_data.items():
#     if value == True:
#         print(666)
#         config_data[key]=False
#         break
#     # print(f"键: {key}, 值: {value}")
#
# # 将修改后的字典写回到config.json文件
# with open('device_id.json', 'w') as json_file:
#     json.dump(config_data, json_file, indent=4)
